package com.risk.kernel.config;

import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.boot.jdbc.DataSourceBuilder;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.jdbc.core.JdbcTemplate;

import javax.sql.DataSource;

/**
 * @author: Liwen
 * @createTime: 2024/11/20
 * @description:
 */

@Configuration
public class DataSourceConfig {
    /**
     * hive 数据源
     * @return
     */
    @Bean(name = "hiveDataSource")
    @Qualifier("hiveDataSource")
    @ConfigurationProperties(prefix = "datasource.hive")
    public DataSource primaryDataSource() {
        return DataSourceBuilder.create().build();
    }

    @Bean(name = "hiveJdbcTemplate")
    public JdbcTemplate hiveJdbcTemplate(
            @Qualifier("hiveDataSource") DataSource dataSource) {
        return new JdbcTemplate(dataSource);
    }

    /**
     * 客服测试环境，数据源
     */

   /* @Bean(name = "kefuConfigDataSource")
    @Qualifier("kefuConfigDataSource")
    @ConfigurationProperties(prefix = "datasource.kefu")
    public DataSource secondaryDataSource() {
        return DataSourceBuilder.create().build();
    }

    @Bean(name = "gmfKeFuJdbcTemplate")
    public JdbcTemplate configJdbcTemplate(
            @Qualifier("kefuConfigDataSource") DataSource dataSource) {
        return new JdbcTemplate(dataSource);
    }*/

}
